package com.sunwayworld.baseline.qywx.login;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

public class RestResult implements Serializable {
    private Integer errcode = 0;
    private String errmsg = "成功";
    private Map<String, Object> data = new HashMap<>();

    public RestResult() {

    }

    public RestResult(Integer errcode) {
        this.errcode = errcode;
    }

    public RestResult(Integer errcode, Map<String, Object> data) {
        this.errcode = errcode;
        this.data = data;
    }

    public RestResult(Integer errcode, String msg, Map<String, Object> data) {
        this.errcode = errcode;
        this.errmsg = msg;
        this.data = data;
    }

    public RestResult(Integer errcode, String msg) {
        this.errcode = errcode;
        this.errmsg = msg;
    }

    public static RestResult ok() {
        return new RestResult(0, "ok");
    }

    public static RestResult error(Integer errcode, String msg) {
        return new RestResult(errcode, msg);
    }

    public Map<String, Object> getData() {
        return data;
    }

    public void setData(Map<String, Object> data) {
        this.data = data;
    }

    public void put(String key, Object object) {
        this.data.put(key, object);
    }
}
